package cn.xiaye.blog.servlet;

import java.util.List;

import cn.xiaye.blog.bean.Article;
import cn.xiaye.blog.bean.Context;
import cn.xiaye.blog.dao.ArticleDao;
import cn.xiaye.blog.db.util.CommonUtil;

@SuppressWarnings("serial")
public class UpdateArticle extends FatherServlet {

	@Override
	public String excute(Context context) {
		if(CommonUtil.isNotLogin(context.getSession())){
			return "login.jsp";
		}
		String name = context.getRequest().getParameter("name");
		String text = context.getRequest().getParameter("text");
		String id = context.getRequest().getParameter("sort_id");
		ArticleDao articleDao = new ArticleDao();
		List<Article> list = articleDao.queryAll();
		context.getRequest().setAttribute("list", list);
		articleDao.update(Integer.valueOf(id), text, name);
		return "admin/update_article.jsp";
	}

}
